﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<PagedList<Customer>>" %>
                                                                            

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Contacts
</asp:Content>

<asp:Content ID="ContentHeader" ContentPlaceHolderID="ContentHeader" runat="server">
Contacts
</asp:Content>

<asp:Content ID="ContentSubNav" ContentPlaceHolderID="ContentSubNav" runat="server">
    <li class="selected"><%= Html.ActionLink("Contacts", "Index", "Customers")%></li>
    <li class=""><%= Html.ActionLink("Create Contact", "Create", "Customers")%></li>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<div class="clearfix" style="border-bottom:2px solid red;margin:0 0 10px;padding:0 0 15px;">
    <a id="filterBtn">Filter</a>
    <input type="submit" class="clearBtn" value="Clear Filter" onClick="location.href='<%= Url.Action((string)null) %>';return false;">

    <div id="filterContainer">
        <div class="faux_form">
            <% Html.RenderPartial("FilterForm", "filter"); %>   
        </div>
    </div>
</div>

<%= Html.ActionLink("Download", "DownloadCustomers", this.ViewContext.GetAllExistingRouteValues(), new Dictionary<string, object>{{"Title", "Download"}, {"Class", "btnDownload"}})%>

<div id="table" style="display:block;">
    <table> 
        <thead>
            <tr>
                <th><%= Html.ColumnHeader("First Name", new SortExpression<Customer>().SortAsc(x => x.FirstName)) %></th>
                <th><%= Html.ColumnHeader("Last Name", new SortExpression<Customer>().SortAsc(x => x.LastName)) %></th>
                <th><%= Html.ColumnHeader("Method", new SortExpression<Customer>().SortAsc(x => x.Method))%></th>
                <th><%= Html.ColumnHeader("Sample Request", new SortExpression<Customer>().SortAsc(x => x.SampleRequest))%></th>
                <th><%= Html.ColumnHeader("Category Name", new SortExpression<Customer>().SortAsc(x => x.Category))%></th>
                <th><%= Html.ColumnHeader("Product Name", new SortExpression<Customer>().SortAsc(x => x.Product))%></th>
                <th></th>
            </tr>
        </thead>
  <% foreach (var customer in Model)
     {
         %>
         
         <tr>
            <td><%= Html.Encode(customer.FirstName != null ? customer.FirstName : "")  %></td>
            <td><%= Html.Encode(customer.LastName != null ? customer.LastName : "")%></td>
            <td><%= Html.Encode(customer.Method.ToDisplayString()) %></td>
            <td><%= Html.Encode(customer.SampleRequest) %></td>
            <td><%= Html.Encode(customer.Category != null ? customer.Category.Name : "") %></td>
            <td><%= Html.Encode(customer.Product != null ? customer.Product.Name : "") %></td>
            <td >
                <span class="btn btnEdit"><%= Html.ActionLink("Edit ", "Edit", new { id = customer.CustomerId }, new { title = "Edit Item", @class = "btn btnEdit" })%></span>
                <span class="btn btnView"><%= Html.ActionLink("View", "Details", new { id = customer.CustomerId }, new { title = "View Item", @class = "btn btnView" })%></span>
            </td>
         </tr>
         
         <%
     }  
       %>
         </table>          
    <%= Html.PagingDiv(Model) %>
          
</div>       
 
</asp:Content>
